package pers.lx.crm.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.lx.crm.base.common.pigeon.Result;
import pers.lx.crm.controller.BaseController;
import pers.lx.crm.entiy.info.InfoListDO;
import pers.lx.crm.entiy.user.UserDO;
import pers.lx.crm.service.system.SystemService;
import pers.lx.crm.service.user.UserService;

/**
 * Created by lxl on 2017/2/22.
 */
@Controller
@RequestMapping(value = "system")
public class SystemController extends BaseController {

    @Autowired
    private SystemService systemService ;

    @Autowired
    private UserService userService ;

    @RequestMapping(value = "/menu",method = RequestMethod.POST)
    public @ResponseBody
    Result getMenu(){
        return systemService.getMenuList() ;
    }

    @RequestMapping(value = "/user/list",method = RequestMethod.POST)
    public @ResponseBody
    Result getUsers(UserDO userDO){
        return userService.getUsers(userDO) ;
    }

    @RequestMapping(value = "/user/add",method = RequestMethod.POST)
    public @ResponseBody
    Result addUser(@RequestBody UserDO userDO){
        return userService.addUser(userDO) ;
    }

    @RequestMapping(value = "/user/update",method = RequestMethod.POST)
    public @ResponseBody
    Result updateUsers(@RequestBody UserDO userDO){
        return userService.updateUser(userDO) ;
    }

    @RequestMapping(value = "/user/remove",method = RequestMethod.POST)
    public @ResponseBody
    Result removeUsers(@RequestBody InfoListDO infoListDO){
        return userService.removeUsers(infoListDO.getUserDOs()) ;
    }

}
